package com.lanhao.aot.excel;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.commons.io.FileUtils;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.google.common.collect.Lists;

import cn.hutool.http.HttpRequest;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;

public class ExcelParseUtil3 {
	
	
	public static void main(String[] args) {
		
		try {
			String readFileToString = FileUtils.readFileToString(new File("D:/sync_json_202405.txt"), "UTF-8");
			com.alibaba.fastjson2.JSONArray parseArray = JSON.parseArray(readFileToString);
			List<String> respList = Lists.newArrayList();
			System.out.println(parseArray.size());
			for (int i = 0; i < parseArray.size(); i++) {
				JSONArray array = new JSONArray();
				com.alibaba.fastjson2.JSONObject o = parseArray.getJSONObject(i);
//				System.out.println(o.toJSONString());
				String orderNo = o.getString("orderNo");
				String bizNo = o.getString("businessNo");
				String rate = o.getString("newFuelAdditionalRate");
				String otherFee = o.getString("newOtherFee");
				array.add(o);
				String respBody = HttpRequest.post("http://shipment.anhelogistics.com/smt-integration/inner/doAttachmentfeeSync").body(array.toString()).execute().body();
				System.out.println("处理附加费同步，businessNo =" + bizNo + ",结果result=" + respBody);
				if(!respBody.contains("账单数据已同步成功或无需同步")) {
					respList.add("[" + bizNo + "]" + respBody);
				}
			}
			
			try {
				FileUtils.writeLines(new File("D:/sync_response_result_20240701.txt"), respList);
			} catch (IOException e) {
				e.printStackTrace();
			}
			
		} catch (IOException e1) {
			e1.printStackTrace();
		}
        
	}
	
}
